<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>环境变量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reserved.variables.session.html">« $_SESSION</a></li>
      <li style="float: right;"><a href="reserved.variables.cookies.html">$_COOKIE »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="reserved.variables.html">预定义变量</a></li>
    <li>环境变量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reserved.variables.environment" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">$_ENV</h1>
  <p class="refpurpose"><span class="refname">$_ENV</span> &mdash; <span class="dc-title">环境变量</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-reserved.variables.environment-description">
  <h3 class="title">说明</h3>
  <p class="para">
   通过环境方式传递给当前脚本的变量的<span class="type"><span class="type 数组">数组</span></span>。
  </p>

  <p class="simpara">
   这些变量被从 PHP 解析器的运行环境导入到 PHP 的全局命名空间。很多是由支持 PHP 运行的 Shell 提供的，并且不同的系统很可能运行着不同种类的 Shell，所以不可能有一份确定的列表。请查看你的 Shell 文档来获取定义的环境变量列表。
  </p>

  <p class="simpara">
   其他环境变量包含了 CGI 变量，而不管 PHP 是以服务器模块还是 CGI 处理器的方式运行。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reserved.variables.environment-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="variable.env.basic">
    <p><strong>示例 #1 <var class="varname">$_ENV</var> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'My&nbsp;username&nbsp;is&nbsp;'&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">$_ENV</span><span style="color: #007700">[</span><span style="color: #DD0000">"USER"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">'!'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>
     假设 &quot;bjori&quot; 运行此段脚本
    </p></div>
    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
My username is bjori!
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-reserved.variables.environment-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para">“Superglobal”也称为自动化的全局变量。这就表示其在脚本的所有作用域中都是可用的。不需要在函数或方法中用
<strong class="command">global $variable;</strong> 来访问它。</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-reserved.variables.environment-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.getenv.html" class="function" rel="rdfs-seeAlso">getenv()</a> - 获取一个环境变量的值</span></li>
    <li class="member"><a href="book.filter.html" class="link">过滤器扩展</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>